package com.fangque.kepp.framework.user.entity;

import com.fangque.kepp.framework.user.AuthoritiesUtil;
import lombok.Data;
import org.springframework.security.core.GrantedAuthority;

import java.util.Collection;
import java.util.List;

/**
 * @author : liyk
 * @version 1.0
 * @date : 2019/11/1 14:08
 */
@Data
public class UserToken {


    private Long id;

    private String username;

    private List<Role> roles;

    public Collection<? extends GrantedAuthority> getAuthorities() {
        return AuthoritiesUtil.getAuthorities(roles);
    }

    public UserToken() {
    }

    public UserToken(String username) {
        this.username = username;
    }
}
